//package com.ruoyi.common.DataConversion.controller;
//
//
//import com.ruoyi.common.DataConversion.service.DownStationInfoService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.*;
//import java.util.stream.Collectors;
//
///**
// * @ClassName DownStationInfoController
// * @Description 下发分站信息
// * @Author 张永永
// * @Date 2020-04-02 17:11
// * @Version 1.0.0.0
// **/
//@RestController
//@CrossOrigin
//@RequestMapping("/monitor/downstationinfo")
//public class DownStationInfoController extends BaseController {
//
//    @Autowired
//    private DownStationInfoService downStationInfoService;
//    @Autowired
//    private StationInfoService stationInfoService;
//    private ExecutorService threadPool = Executors.newCachedThreadPool();
//
//    @Autowired
//    private RealStationInfoService realStationInfoService;
//
//    /**
//     * 下发分站时钟同步信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/sendStationClock", produces = "application/json;charset=UTF-8")
//    public AjaxResult sendStationClock(@RequestBody HashMap<String, Object> param) {
//        try {
//            Map<String, Object> stationMap = downStationInfoService.sendStationClock(param.get("stationCode").toString());
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, stationMap);
//
//        } catch (Exception ex) {
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//    /**
//     * 下发分站电源管理信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/powerInfoManager", produces = "application/json;charset=UTF-8")
//    public AjaxResult powerInfoManager(@RequestBody HashMap<String, Object> param) {
//        try {
//            Map<String, Object> powerManagerMap = downStationInfoService.powerInfoManager(param.get("stationCode").toString(), param.get("powerAction").toString());
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, powerManagerMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//    /**
//     * 下发分站高级电源管理信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/powerInfoManagerPlus", produces = "application/json;charset=UTF-8")
//    public AjaxResult powerInfoManagerPlus(@RequestBody HashMap<String, Object> param) {
//        try {
//            Map<String, Object> powerManagerPlusMap = downStationInfoService.powerInfoManagerPlus(param.get("stationCode").toString(), param.get("powerDeviceCode").toString(), param.get("powerAction").toString());
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, powerManagerPlusMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//    /**
//     * 下发分站新告警包信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/newAlarmInfoManager", produces = "application/json;charset=UTF-8")
//    public AjaxResult newAlarmInfoManager(@RequestBody HashMap<String, Object> param) {
//        try {
//            List<HashMap<String, Object>> filterCardReader = MainObject.CARD_READER_INFO_LIST.stream()
//                    .filter(a -> a.get("ReaderCode").toString()
//                            .equals(param.get("cardReaderId").toString())).collect(Collectors.toList());
//            String stationCode = "";
//            if (filterCardReader.size() > 0) {
//                stationCode = filterCardReader.get(0).get("StationCode").toString();
//            } else {
//                stationCode = param.get("stationCode").toString();
//            }
//            String isInSideMassage;
//            //isInSideMassage为空说明是联动告警
//            if (param.get("isInSideMassage") == null) {
//                isInSideMassage = "0";
//            } else {
//                //isInSideMassage为 “1”说明是系统内部下发告警
//                isInSideMassage = param.get("isInSideMassage").toString();
//            }
//            Map<String, Object> alarmInfoMap = downStationInfoService.newAlarmInfoManager(stationCode
//                    , param.get("cardDeviceId").toString()
//                    , param.get("cardReaderId").toString()
//                    , param.get("alarmType").toString()
//                    , param.get("alarmState").toString()
//                    , isInSideMassage);
//            return success(AjaxResult.Type.SUCCESS, alarmInfoMap.get("result").toString(), alarmInfoMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//
//    /**
//     * 下发读卡器读参数包
//     *
//     * @return
//     */
//    @PostMapping(value = "/cardReaderParamRead", produces = "application/json;charset=UTF-8")
//    public AjaxResult cardReaderParamRead(@RequestBody HashMap<String, Object> param) {
//        try {
//            List<HashMap<String, Object>> filterCardReader = MainObject.CARD_READER_INFO_LIST.stream()
//                    .filter(a -> a.get("ReaderCode").toString()
//                            .equals(param.get("cardReaderId").toString())).collect(Collectors.toList());
//            String stationCode = "";
//            if (filterCardReader.size() > 0) {
//                stationCode = filterCardReader.get(0).get("StationCode").toString();
//            } else {
//                stationCode = param.get("stationCode").toString();
//            }
//
//            Map<String, Object> cardReaderParamReadMap = downStationInfoService.cardReaderParamRead(stationCode, param.get("cardReaderId").toString(), param.get("paramNum").toString());
//            Map<String, Object> cardReaderParamReadHash = new HashMap<>();
//            cardReaderParamReadHash.put("result", cardReaderParamReadMap.get("ReceiveResult").toString());
//            cardReaderParamReadHash.put("ResultContent", cardReaderParamReadMap.get("ResultContent") != null ? cardReaderParamReadMap.get("ResultContent").toString() : "");
//            if (cardReaderParamReadMap.get("ReceiveResult").toString().equals("操作成功")) {
//                return success(AjaxResult.Type.SUCCESS, cardReaderParamReadMap.get("ReceiveResult").toString(), cardReaderParamReadHash);
//            }
//            return error(AjaxResult.Type.ERROR, cardReaderParamReadMap.get("ReceiveResult").toString(), cardReaderParamReadHash);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 下发读卡器写参数包
//     *
//     * @return
//     */
//    @PostMapping(value = "/cardReaderParamWrite", produces = "application/json;charset=UTF-8")
//    public AjaxResult cardReaderParamWrite(@RequestBody HashMap<String, Object> param) {
//        try {
//            List<HashMap<String, Object>> filterCardReader = MainObject.CARD_READER_INFO_LIST.stream()
//                    .filter(a -> a.get("ReaderCode").toString()
//                            .equals(param.get("cardReaderId").toString())).collect(Collectors.toList());
//            String stationCode = "";
//            if (filterCardReader.size() > 0) {
//                stationCode = filterCardReader.get(0).get("StationCode").toString();
//            } else {
//                stationCode = param.get("stationCode").toString();
//            }
//
//            Map<String, Object> cardReaderParamWriteMap = downStationInfoService.cardReaderParamWrite(stationCode, param.get("cardReaderId").toString(), param.get("paramNum").toString(), param.get("paramValue").toString());
//            Map<String, Object> cardReaderParamWriteHash = new HashMap<>();
//            cardReaderParamWriteHash.put("result", cardReaderParamWriteMap.get("ReceiveResult").toString());
//            if (cardReaderParamWriteMap.get("ReceiveResult").toString().equals("操作成功")) {
//                return success(AjaxResult.Type.SUCCESS, cardReaderParamWriteMap.get("ReceiveResult").toString(), cardReaderParamWriteHash);
//            }
//            return error(AjaxResult.Type.ERROR, cardReaderParamWriteMap.get("ReceiveResult").toString(), cardReaderParamWriteHash);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 下发标识卡报警短信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8")
//    public AjaxResult sendMessage(@RequestBody HashMap<String, Object> param) {
//        try {
//            List<HashMap<String, Object>> filterCardReader = MainObject.CARD_READER_INFO_LIST.stream()
//                    .filter(a -> a.get("ReaderCode").toString()
//                            .equals(param.get("cardReaderId").toString())).collect(Collectors.toList());
//            String stationCode = "";
//            if (filterCardReader.size() > 0) {
//                stationCode = filterCardReader.get(0).get("StationCode").toString();
//            } else {
//                stationCode = param.get("stationCode").toString();
//            }
//            Map<String, Object> messageMap = downStationInfoService.sendMessage(stationCode
//                    , param.get("cardDeviceId").toString()
//                    , param.get("cardReaderId").toString()
//                    , param.get("alarmType").toString()
//                    , param.get("messageContent").toString());
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, messageMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 下发标识卡信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/sendCardInfo", produces = "application/json;charset=UTF-8")
//    public AjaxResult sendCardInfo(@RequestBody HashMap<String, Object> param) {
//        try {
//            List<HashMap<String, Object>> listRealStation = realStationInfoService.listRealStation();
//            List<HashMap<String, Object>> collect = listRealStation.stream()
//                    .filter(realStation -> realStation.get("StationCode").equals(param.get("stationCode")))
//                    .filter(realStation -> realStation.get("StationStatus").equals("在线"))
//                    .collect(Collectors.toList());
//
//            if (collect.size() > 0) {
//                if (collect.get(0).get("StationType").equals("读卡分站")) {
//                    threadPool.execute(() -> downStationInfoService.sendCardInfo(param.get("stationCode").toString()));
//                } else {
//                    return error(AjaxResult.Type.ERROR, "该分站为" + collect.get(0).get("StationType") + "请按" + collect.get(0).get("StationType") + "方式配置信息", CommonEnum.OPERATION_FAIL);
//                }
//            } else {
//                return error(AjaxResult.Type.ERROR, "分站离线", CommonEnum.OPERATION_FAIL);
//            }
//            return success(AjaxResult.Type.SUCCESS, "发送启动", CommonEnum.OPERATION_SUCCESS);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 返回发送标识卡信息的状态与进度
//     *
//     * @return
//     */
//    @PostMapping(value = "/sendCardInfoProcess", produces = "application/json;charset=UTF-8")
//    public AjaxResult sendCardInfoProcess() {
//        try {
//
//            Map<String, Object> resultMap = new HashMap();
//            System.out.println(MainObject.PROGRESS_OF_ISSUING_PERSON_CARD_INFORMATION);
//            if (MainObject.PROGRESS_OF_ISSUING_PERSON_CARD_INFORMATION.get("status") == null || MainObject.PROGRESS_OF_ISSUING_PERSON_CARD_INFORMATION.get("process") == null) {
//                return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//            }
//
//            resultMap.put("status", MainObject.PROGRESS_OF_ISSUING_PERSON_CARD_INFORMATION.get("status"));
//            resultMap.put("process", MainObject.PROGRESS_OF_ISSUING_PERSON_CARD_INFORMATION.get("process"));
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, resultMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 下发读卡器信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/sendCardReaderInfo", produces = "application/json;charset=UTF-8")
//    public AjaxResult sendCardReaderInfo(@RequestBody HashMap<String, Object> param) {
//        try {
//            List<HashMap<String, Object>> listRealStation = realStationInfoService.listRealStation();
//            List<HashMap<String, Object>> collect = listRealStation.stream()
//                    .filter(realStation -> realStation.get("StationCode").equals(param.get("stationCode")))
//                    .filter(realStation -> realStation.get("StationStatus").equals("在线"))
//                    .collect(Collectors.toList());
//            if (collect.size() > 0) {
//                //通过分站Code获取相应的分站信息
//                HashMap<String, Object> stationMap = new HashMap<>();
//                stationMap.put("StationCode", param.get("stationCode").toString());
//                List<HashMap<String, Object>> stationFilterList = stationInfoService.findStationInfo(stationMap);
//                if (stationFilterList.size() > 0) {
//                    if (collect.get(0).get("StationType").equals("读卡分站")) {
//                        threadPool.execute(new Runnable() {
//                            @Override
//                            public void run() {
//                                downStationInfoService.sendCardReaderInfo(param.get("stationCode").toString());
//                            }
//                        });
//                    } else {
//                        return error(AjaxResult.Type.ERROR, "该分站为" + collect.get(0).get("StationType") + "请按" + collect.get(0).get("StationType") + "方式配置信息", CommonEnum.OPERATION_FAIL);
//                    }
//                } else {
//                    return error(AjaxResult.Type.ERROR, "本分站下没有读卡器", CommonEnum.OPERATION_FAIL);
//                }
//            } else {
//                return error(AjaxResult.Type.ERROR, "分站离线", CommonEnum.OPERATION_FAIL);
//            }
//            return success(AjaxResult.Type.SUCCESS, "下发读卡器信息启动", CommonEnum.OPERATION_SUCCESS);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 返回发送读卡器信息的状态与进度
//     *
//     * @return
//     */
//    @PostMapping(value = "/sendCardReaderInfoProcess", produces = "application/json;charset=UTF-8")
//    public AjaxResult sendCardReaderInfoProcess() {
//        try {
//            Map<String, Object> resultMap = new HashMap();
//            System.out.println(MainObject.PROGRESS_OF_ISSUING_READER_CARD_INFORMATION);
//            if (MainObject.PROGRESS_OF_ISSUING_READER_CARD_INFORMATION.get("status") == null || MainObject.PROGRESS_OF_ISSUING_READER_CARD_INFORMATION.get("process") == null) {
//                return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//            }
//            resultMap.put("status", MainObject.PROGRESS_OF_ISSUING_READER_CARD_INFORMATION.get("status"));
//            resultMap.put("process", MainObject.PROGRESS_OF_ISSUING_READER_CARD_INFORMATION.get("process"));
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, resultMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 读取全部基本参数
//     *
//     * @return
//     */
//    @PostMapping(value = "/readStationBaseParam", produces = "application/json;charset=UTF-8")
//    public AjaxResult readStationBaseParam(@RequestBody HashMap<String, Object> param) {
//        try {
//            StationBaseParameter stationBaseParameter = new StationBaseParameter();
//            Map<String, Object> stationMap = downStationInfoService.readStationParam(param.get("StationID").toString(),
//                    "0100", 60, stationBaseParameter);
//
//            Map<String, Object> readStationParamHash = new HashMap<>();
//            readStationParamHash.put("result", stationMap.get("ReceiveResult"));
//            StationBaseParameter parameter = stationMap.get("ResultContent") != null
//                    ? (StationBaseParameter) stationMap.get("ResultContent")
//                    : null;
//            readStationParamHash.put("StationAddress", parameter != null ? parameter.getStationAddress() : "");
//            readStationParamHash.put("PowerProtocol", parameter != null ? parameter.getPowerProtocol() : "");
//            readStationParamHash.put("readerPollingParameters", parameter != null ? parameter.getReaderPollingParameters() : "");
//            readStationParamHash.put("powerPollingParameters", parameter != null ? parameter.getPowerPollingParameters() : "");
//            readStationParamHash.put("PowerNumber", parameter != null ? parameter.getPowerNumber() : "");
//            readStationParamHash.put("MasterPowerAddress", parameter != null ? parameter.getMasterPowerAddress() : "");
//            readStationParamHash.put("RelayPowerOne", parameter != null ? parameter.getRelayPowerOne() : "");
//            readStationParamHash.put("RelayPowerTwo", parameter != null ? parameter.getRelayPowerTwo() : "");
//            readStationParamHash.put("RelayPowerThree", parameter != null ? parameter.getRelayPowerThree() : "");
//            readStationParamHash.put("FrameType", parameter != null ? parameter.getFrameType() : "");
//            readStationParamHash.put("histringDateBacktrackSwitch", parameter != null ? parameter.getHistringDateBacktrackSwitch() : "");
//            readStationParamHash.put("histringDateBacktrackBase", parameter != null ? parameter.getHistringDateBacktrackBase() : "");
//
//            if (stationMap.get("ReceiveResult").toString().equals("操作成功")) {
//                return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, readStationParamHash);
//            } else {
//                return fail(AjaxResult.Type.FAIL, CommonEnum.OPERATION_FAIL, readStationParamHash);
//            }
//
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//    /**
//     * 读取全部端口配置信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/readStationPortParam", produces = "application/json;charset=UTF-8")
//    public AjaxResult readStationPortParam(@RequestBody HashMap<String, Object> param) {
//        try {
//            PortParameter portParameter = new PortParameter();
//            int startAddress = Integer.parseInt(param.get("StartAddress").toString(), 16);
//            String addressHex = Integer.toHexString(startAddress);
//            Map<String, Object> stationMap = downStationInfoService.readStationParam(param.get("StationID").toString(),
//                    addressHex, 48, portParameter);
//
//            Map<String, Object> readStationParamHash = new HashMap<>();
//            readStationParamHash.put("result", stationMap.get("ReceiveResult"));
//            PortParameter parameter =
//                    stationMap.get("ResultContent") != null
//                            ? (PortParameter) stationMap.get("ResultContent")
//                            : null;
//
//            readStationParamHash.put("PortSwitch", parameter != null ? parameter.getPortSwitch() : "");
//            readStationParamHash.put("PortBaudrate", parameter != null ? parameter.getPortBaudrate() : "");
//            readStationParamHash.put("ReaderCount", parameter != null ? parameter.getReaderCount() : "");
//            readStationParamHash.put("ReaderOneCode", parameter != null ? parameter.getReaderOneCode() : "");
//            readStationParamHash.put("ReaderTwoCode", parameter != null ? parameter.getReaderTwoCode() : "");
//            readStationParamHash.put("ReaderThreeCode", parameter != null ? parameter.getReaderThreeCode() : "");
//            readStationParamHash.put("ReaderFourCode", parameter != null ? parameter.getReaderFourCode() : "");
//            readStationParamHash.put("ReaderFiveCode", parameter != null ? parameter.getReaderFiveCode() : "");
//            readStationParamHash.put("ReaderSixCode", parameter != null ? parameter.getReaderSixCode() : "");
//            readStationParamHash.put("ReaderSevenCode", parameter != null ? parameter.getReaderSevenCode() : "");
//            readStationParamHash.put("ReaderEightCode", parameter != null ? parameter.getReaderEightCode() : "");
//
//            if (stationMap.get("ReceiveResult").toString().equals("操作成功")) {
//                return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, readStationParamHash);
//            } else {
//                return fail(AjaxResult.Type.FAIL, CommonEnum.OPERATION_FAIL, readStationParamHash);
//            }
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//    /**
//     * 读单个基本信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/readStationSingleParam", produces = "application/json;charset=UTF-8")
//    public AjaxResult readStationSingleParam(@RequestBody HashMap<String, Object> param) {
//        try {
//            int startAddress = Integer.parseInt(param.get("StartAddress").toString(), 16);
//            String addressHex = Integer.toHexString(startAddress);
//
//            StationSingleParam stationSingleParam = new StationSingleParam();
//            stationSingleParam.setSingleParam(startAddress);
//            Map<String, Object> stationMap = downStationInfoService.readStationParam(param.get("StationID").toString(),
//                    addressHex, 4, stationSingleParam);
//
//            Map<String, Object> readStationParamHash = new HashMap<>();
//            readStationParamHash.put("result", stationMap.get("ReceiveResult"));
//            StationSingleParam parameter =
//                    stationMap.get("ResultContent") != null
//                            ? (StationSingleParam) stationMap.get("ResultContent")
//                            : null;
//
//            readStationParamHash.put("ReturnParam", parameter != null ? parameter.getReturnParam() : "");
//
//            if (stationMap.get("ReceiveResult").toString().equals("操作成功")) {
//                return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, readStationParamHash);
//            } else {
//                return fail(AjaxResult.Type.FAIL, CommonEnum.OPERATION_FAIL, readStationParamHash);
//            }
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//
//    /**
//     * 写单个基本信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/writeStationParam", produces = "application/json;charset=UTF-8")
//    public AjaxResult writeStationParam(@RequestBody HashMap<String, Object> param) {
//        try {
//            int startAddress = Integer.parseInt(param.get("StartAddress").toString(), 16);
//            String addressHex = Integer.toHexString(startAddress);
//            Map<String, Object> cardReaderMap = downStationInfoService.writeStationParam(param.get("StationID").toString()
//                    , addressHex
//                    , Integer.parseInt(param.get("DataContent").toString()));
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, cardReaderMap);
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 写单个端口参数
//     *
//     * @return
//     */
//    @PostMapping(value = "/writeStationPortParam", produces = "application/json;charset=UTF-8")
//    public AjaxResult writeStationPortParam(@RequestBody HashMap<String, Object> param) {
//        try {
//            int startAddress = Integer.parseInt(param.get("SpecificAddress").toString(), 16)
//                    + Integer.parseInt(param.get("StartAddress").toString(), 16);
//            String addressHex = Integer.toHexString(startAddress);
//
//            Map<String, Object> cardReaderMap = downStationInfoService.writeStationParam(param.get("StationID").toString()
//                    , addressHex
//                    , Integer.parseInt(param.get("DataContent").toString()));
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, cardReaderMap);
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_FAIL, null);
//        }
//    }
//
//    /**
//     * 读取单个端口信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/readStationPortSingleParam", produces = "application/json;charset=UTF-8")
//    public AjaxResult readStationPortSingleParam(@RequestBody HashMap<String, Object> param) {
//        try {
//            int startAddress = Integer.parseInt(param.get("SpecificAddress").toString(), 16)
//                    + Integer.parseInt(param.get("StartAddress").toString(), 16);
//            String addressHex = Integer.toHexString(startAddress);
//
//            StationSingleParam stationSingleParam = new StationSingleParam();
//            stationSingleParam.setSingleParam(startAddress);
//            Map<String, Object> stationMap = downStationInfoService.readStationParam(param.get("StationID").toString(),
//                    addressHex, 4, stationSingleParam);
//
//            Map<String, Object> readStationParamHash = new HashMap<>();
//            readStationParamHash.put("result", stationMap.get("ReceiveResult"));
//            StationSingleParam parameter =
//                    stationMap.get("ResultContent") != null
//                            ? (StationSingleParam) stationMap.get("ResultContent")
//                            : null;
//
//            readStationParamHash.put("ReturnParam", parameter != null ? parameter.getReturnParam() : "");
//
//            if (stationMap.get("ReceiveResult").toString().equals("操作成功")) {
//                return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, readStationParamHash);
//            } else {
//                return fail(AjaxResult.Type.FAIL, CommonEnum.OPERATION_FAIL, readStationParamHash);
//            }
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//    /**
//     * 卡模式切换
//     *
//     * @return
//     */
//    @PostMapping(value = "/cardModeChange", produces = "application/json;charset=UTF-8")
//    public AjaxResult cardModeChange(@RequestBody HashMap<String, Object> param) {
//        try {
//            Map<String, Object> cardModeChangeMap
//                    = downStationInfoService.cardModeChange(param.get("stationID").toString(),
//                    param.get("startCardDeviceCode").toString(),param.get("endCardDeviceCode").toString(),
//                    param.get("mode").toString());
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, cardModeChangeMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//
//    /**
//     * 标识卡模式切换取消
//     * @param param
//     * @return
//     */
//    @PostMapping(value = "/cardModeChangeCancel", produces = "application/json;charset=UTF-8")
//    public Map<String, Object> cardModeChangeCancel(@RequestBody HashMap<String, Object> param){
//        try {
//            Map<String, Object> cardModeChangeMap
//                    = downStationInfoService.cardModeChangeCancel(param.get("stationID").toString());
//            return success(AjaxResult.Type.SUCCESS, CommonEnum.OPERATION_SUCCESS, cardModeChangeMap);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(AjaxResult.Type.ERROR, CommonEnum.OPERATION_EXCEPTION, null);
//        }
//    }
//}
